﻿/// <reference path="../../Context/js/jquery-1.7.2.min.js" />
var _url = "http://" + window.location.host;
$(document).ready(function () {
    //$(".dataTable").dataTable({sSortDataType:[[0, 'asc']] });
    // dataTable();
    select();
    numberIncrement();
    $("#content").css({ height: "auto" });
    dataTable();
    pingWebsite();
    selectlanguage();
});
//-------------------------------------------****** Configs ********----------------------
function shippingmethod() {
    genUpValue("shipUpVal", "act");
    genUpValue("shipDel", "delete");
    genValText("shipUpVal", "order")
}

function paymentmethod() {
    genUpValue("payUpVal", "act");
    genUpValue("payDel", "delete");
    genValText("payUpVal", "order")
}
//-------------------------------------------****** product ********----------------------
//Product manage
function productBuss() {

    genUpValue("ProdUpVal", "exists");
    genUpValue("ProdUpVal", "vat");
    genUpValue("ProdUpVal", "new");
    genUpValue("ProdUpVal", "hot");
    genUpValue("ProdUpVal", "sellgood");
    genUpValue("ProdUpVal", "promotion");
    genUpValue("ProdUpVal", "act");
    genUpValue("prodDel", "delete");
    genValText("ProdUpVal", "order");
   
}

function ProductEdit(eleAttr, eleAttrValue, prodID) {
    $.fn.editable.defaults.url = _url + '/Services/AttributeResponse.ashx';
    var loadAttrValue = function (attID) {
        $.post(_url + '/Services/AttributeResponse.ashx', { name: 'listattrvalue', AID: attID }, function (data, status) {
            var htmlSelect = "";
            if (data != null && data != 'null') {
                data = $.evalJSON(data);
                $.each(data, function (index, obj) {
                    htmlSelect += "<option value='" + obj.AttributeValueID + "'>" + obj.Value + "</option>"
                });
            }
            $(eleAttrValue).html(htmlSelect);
        });
    };
    var HienthiThuocTinh = function () {
        var list_tr = $("#user tbody tr");
        var idAttr = 0;
        $.each(list_tr, function (index, obj) {
            idAttr = $(obj).find("td").eq(1).text();
            if ($.isNumeric(idAttr))
                $(obj).find("td").eq(1).text($(eleAttr).find("option[value=" + idAttr + "]").text());
        });
    };
    var delAttr = function () {
        $(".delete").click(function (ev) {
            ev.preventDefault();
            var $objTr = $(this);
            $.post(_url + '/Services/AttributeResponse.ashx', { name: 'delattrprod', AID: $(this).attr("data-attrid") }, function (data, status) {
                data = data * 1;
                if (data > 0)
                    $objTr.parent().parent().remove();
            });
        });
    };
    var loadAttrSelect = function () {
        $(".editable").editable({
            source: function () {
                var arr = [];
                $.ajax({
                    type: "POST",
                    url: _url + '/Services/AttributeResponse.ashx',
                    dataType: "json",
                    data: { name: 'listattrvalue', AID: $(this).attr("data-attrid") },
                    success: function (data) {
                        if (data != 'null' && data != null) {
                            $.each(data, function (index, obj) {
                                arr.push({ value: obj.AttributeValueID, text: obj.Value });
                            });
                        }
                    },
                    async: false
                });
                return arr;
            }
        });
    };
    delAttr();
    HienthiThuocTinh();
    loadAttrSelect();
    loadAttrValue($(eleAttr).val());    
    $(eleAttr).change(function () { loadAttrValue($(this).val()); });
    $("#addRow").click(function () {
        $.post(_url + '/Services/AttributeResponse.ashx', { name: 'addattrprod', prodid: prodID, AID: $(eleAttrValue).val() }, function (data, status) {
            var html = "";
            data = parseInt(data);
            if (data > 0) {
                html = '<tr><td>' + ($("#user tbody tr").length + 1) + '</td>' +
         '<td>' + $(eleAttr).find("option:selected").text() + '</td>' +
         '<td><i data-value="' + $(eleAttrValue).val() + '" data-attrid="' + $(eleAttr).val() + '" data-name="editattval1" data-type="select" data-pk="' + data + ',' + prodID + '" data-placement="right" data-placeholder="Required" data-original-title="Chọn giá trị" class="editable editable-click editable-empty">' + $(eleAttrValue).find("option:selected").text() + '</i></td>' +
         '<td class="tb-stt"><a href="#" data-attrid="' + data + '" class="btn delete" rel="tooltip" title="" data-original-title="Edit"><i class="fa fa-edit"></i></a></td>';
                $("#user tbody").append(html);
                delAttr();
                HienthiThuocTinh();
                loadAttrSelect();
            } else {
                if (data == -1)
                    alert("Thuộc tính này đã tồn tại.");
            }
        });
    });
}

function manufacturer() {
    genUpValue("manuUpVal", "act");
    genUpValue("manuDel", "delete");
    genValText("manuUpVal", "order")
}

function attribute() {
    genUpValue("attrUpVal", "act");
    genUpValue("attrDel", "delete");
    genValText("attrUpVal", "order")
}

function attrbuteEdit(attID) {
    $.mockjaxSettings.responseTime = 500;
    $.fn.editable.defaults.url = _url + '/Services/AttributeResponse.ashx';
    $('.editable').editable();
    var strHtml = "";
    var $thisdel = null;
    var delAttr = function () {
        $("a.Delete").click(function (ev) {
            ev.preventDefault();
            $thisdel = $(this);
            $.post(_url + '/Services/AttributeResponse.ashx', { name: 'delattvalue', delattvalue: $(this).attr("href") }, function (data, status) {
                if (data == "1")
                    $thisdel.parent().parent().remove();
            });
        });
    };
    delAttr();
    $("#addRow").click(function () {
        var txtValue = $("#txtValue").val();
        var txtOrder = $("#txtOrder").val();
       
        if (txtValue.length > 0 && txtOrder.length > 0) {
            $.post(_url + '/Services/AttributeResponse.ashx', { name: 'add', value: txtValue, pk: txtOrder, AID: attID }, function (data, status) {
                if (data > 0 && status == 'success') {
                    strHtml = '<tr><td>' + $("#user tbody tr").length + '</td>' +
           '<td><i data-name="editvalue" data-type="text" data-pk="' + data + '" data-placement="right" data-placeholder="Required" data-original-title="Nhập tên thuộc tính" class="editable editable-click editable-empty">' + $("#txtValue").val() + '</i></td>' +
           '<td><i data-name="editvalue" data-type="text" data-pk="' + data + '" data-placement="right" data-placeholder="Required" data-original-title="Nhập tên thuộc tính" class="editable editable-click editable-empty">' + $("#txtOrder").val() + '</i></td>'+
           '<td class="tb-gen-1"><a href="' + data + '" class="btn Delete" rel="tooltip" title="" data-original-title="Xóa"><i class="fa fa-times"></i></a></td></tr>';
                    $("#user tbody").append(strHtml);
                    $('.editable').editable();
                    $('[rel=tooltip]').tooltip();
                    delAttr();
                }
                console.log(status);
            });
        } else alert("Yêu cầu bạn nhập giá trị cho thuộc tính!");
    });
}
//-------------------------------------------****** content ********----------------------
function Gallery() {
    GeneralDelete("delGallery");
    genUpValue("GelleryUp", "act");
    genValText("GelleryUp", "order");
}

function ScriptNews() {
    GeneralDelete("NewsDelete");
    GeneralActive("NewsActive");
    genValText("NewsOrder", "order");
}

function Advs() {
    GeneralDelete("delAdvs");
    genUpValue("AdvUp", "act");
    genValText("AdvUp", "order");
}
//-------------------------------------------****** category ********----------------------
function Categories() {
    GeneralDelete("CateDelete");
    GeneralActive("CateActive");
    genValText("CateOrder", "order");
}
//-------------------------------------------****** customer ********----------------------
function customerMange() {
    GeneralDelete("delCust");
}

function OrderProduct() {
    genUpValue("orderUpVal", "act");
    genUpValue("orderDel", "delete");
}

function Poll() {
    GeneralDelete("delPoll");
    genUpValue("PollOrder", "act");
    genValText("PollOrder", "order");
}

function Support() {
    GeneralDelete("delSupport");
    GeneralActive("SupportActive");
    genUpValue("SupportOrder", "order");
}

function Contact() {
    $(".edit").colorbox({ inline: true, width: "50%" });
    $(".edit").click(function (ev) {
        ev.preventDefault();
        CallMethodSV("getContact", $.toJSON({ cid: $(this).attr("data-cid") }), function (d) {
            if (d.d != null) {
                var obj = d.d;
                $("#fullname").text(obj.Fullname);
                $("#email").text(obj.Email);
                $("#address").text(obj.Address);
                $("#company").text(obj.Company);
                $("#phone").text(obj.PhoneNumber);
                $("#title").text(obj.Title);
                $("#contentContact").text(obj.Content);
            } else {
                $("#fullname").text("");
                $("#email").text("");
                $("#address").text("");
                $("#company").text("");
                $("#phone").text("");
                $("#title").text("");
                $("#contentContact").text("");
            }
        }, true);
    });
    GeneralDelete("delContact");
}

function downloadmanage() {
    GeneralDelete("DownDelete");
    genUpValue("DownUpVal", "act");
    genValText("DownUpVal", "order");
}
//-------------------------------------------****** Configs ********----------------------
//Tabs
function selectlanguage() {
    if ($(".selectlanguage").length > 0) {
        $(".selectlanguage").change(function () {
            var $parent = $($(this).val()).parent();
            $parent.children(".tab-pane").removeClass("active");
            $($(this).val()).addClass("active");
            //$($(this).val()).find(".tab-pane").eq(0).addClass("active");
        });
    }
}
//-------------------------------------------****** table ********----------------------

function pingWebsite() {
    var RunAutoPing = function () {
        $.get(_url + "/Services/ProductCart.ashx?type=ping", {}, function (data, status) {
            console.log(data);
        });
    };
    RunAutoPing();
    setInterval(RunAutoPing, 5000);

}

function dataTable() {
    // dataTables
    if ($('.dataTable-1').length > 0) {
        PlugInTable();
        $('.dataTable-1').each(function () {
            if (!$(this).hasClass("dataTable-custom")) {
                var opt = {
                    "sPaginationType": "full_numbers",
                    "oLanguage": {
                        "sSearch": "<span>Tìm kiếm:</span> ",
                        "sInfo": "Showing <span>_START_</span> to <span>_END_</span> of <span>_TOTAL_</span> entries",
                        "sLengthMenu": "_MENU_ <span>Số dòng trên 1 trang</span>"
                    },
                    'sDom': "lfrtip"
                };
                opt.aLengthMenu = [[25, 50, 75, -1], [25, 50, 75, 'All']];
                if ($(this).hasClass("dataTable-noheader")) {
                    opt.bFilter = false;
                    opt.bLengthChange = false;
                }
                if ($(this).hasClass("dataTable-nofooter")) {
                    opt.bInfo = false;
                    opt.bPaginate = false;
                }
                if ($(this).hasClass("dataTable-nosort")) {
                    var column = $(this).attr('data-nosort');
                    column = column.split(',');
                    for (var i = 0; i < column.length; i++) {
                        column[i] = parseInt(column[i]);
                    };
                    opt.aoColumnDefs = [{
                        'bSortable': false,
                        'aTargets': column
                    }];
                }
                var colLast = $('.dataTable-1 tbody tr td').last().index();
                if ($(".category-select").length > 0)
                    colLast = colLast - 1;
                opt.aoColumnDefs = [{ 'bSortable': false, 'aTargets': [1], 'sWidth': '50px', sClass: 'tb-gen-1' },
                    { 'aTargets': [0], 'sWidth': '50px', sClass: 'tb-gen-1' },
                    /// { 'aTargets': [colLast - 1], "sSortDataType": "dom-numeric", "sType": "numeric" },
                    { 'bSortable': false, 'aTargets': [colLast] }];
                if ($(this).hasClass("dataTable-scroll-x")) {
                    opt.sScrollX = "100%";
                    opt.bScrollCollapse = true;
                    $(window).resize(function () {
                        oTable.fnAdjustColumnSizing();
                    });
                }
                if ($(this).hasClass("dataTable-scroll-y")) {
                    opt.sScrollY = "300px";
                    opt.bPaginate = false;
                    opt.bScrollCollapse = true;
                    $(window).resize(function () {
                        oTable.fnAdjustColumnSizing();
                    });
                }
                if ($(this).hasClass("dataTable-reorder")) {
                    opt.sDom = "R" + opt.sDom;
                }
                if ($(this).hasClass("dataTable-colvis")) {
                    opt.sDom = "C" + opt.sDom;
                    opt.oColVis = {
                        "buttonText": "Change columns <i class='fa fa-angle-down'></i>"
                    };
                }
                if ($(this).hasClass('dataTable-tools')) {
                    opt.sDom = "T" + opt.sDom;
                    opt.oTableTools = {
                        "sSwfPath": "http://" + window.location.host + "http://static.mpsoft.vn/Context/js/plugins/datatable/swf/copy_csv_xls_pdf.swf"
                    };
                }
                if ($(this).hasClass("dataTable-scroller")) {
                    opt.sScrollY = "300px";
                    opt.bDeferRender = true;
                    if ($(this).hasClass("dataTable-tools")) {
                        opt.sDom = 'TfrtiS';
                    } else {
                        opt.sDom = 'frtiS';
                    }
                }
                if ($(this).hasClass("dataTable-grouping") && $(this).attr("data-grouping") == "expandable") {
                    opt.bLengthChange = false;
                    opt.bPaginate = false;
                }
                if ($(".table-product").length > 0) {
                    opt.aoColumnDefs = [{ 'bSortable': false, 'aTargets': [1, 3, 4, 5, 6, 7, 8, 9, 10], 'sWidth': '50px', sClass: 'tb-gen-1' },
                   { 'aTargets': [0], 'sWidth': '50px', sClass: 'tb-gen-1' },
                    { 'aTargets': [colLast - 1], "sSortDataType": "dom-numeric", "sType": "numeric" },
                   { 'bSortable': false, 'aTargets': [colLast], 'sWidth': '100px'}];

                }
                
                var oTable = $(this).dataTable(opt);
                $(this).css("width", '100%');
                $('.dataTables_filter input').attr("placeholder", "Tìm kiếm...").addClass("form-control input-medium");
                $(".dataTables_length select").wrap("<div class='input-mini'></div>").chosen({ disable_search_threshold: 9999999 });
               
                $("#check_all").click(function (e) {
                    if(this.checked)
                        $('input[name=check]', oTable.fnGetNodes()).parent().addClass("checked");
                    else
                        $('input[name=check]', oTable.fnGetNodes()).parent().removeClass("checked");
                });
                if ($(".table-7").length > 0) {
                    oTable.columnFilter({
                        "sPlaceHolder": "head:after",
                        "aoColumns": [null, null, { type: "text" }, {
                            type: "select", bCaseSensitive: true,
                            values: ['Đã bật', 'Chưa bật']
                        }, null, null]
                    });
                }
                if ($(".table-8").length > 0) {
                    oTable.columnFilter({
                        "sPlaceHolder": "head:after",
                        "aoColumns": [null, null, null, { type: "text" },
                            {type: "select", bCaseSensitive: true,values: ['Đã bật', 'Chưa bật']},null, null, null]
                    });
                }
                if ($(".table-categories").length > 0) {
                    oTable.columnFilter({
                        "sPlaceHolder": "head:after",
                        "aoColumns": [null, null, { type: "text" }, {
                            type: "select", bCaseSensitive: true,
                            values: ['Sản phẩm', 'Tin tức', 'Bài viết', "Download", "Thư viện ảnh", "Hệ thống"]
                        }, {
                            type: "select", bCaseSensitive: true,
                            values: ['Đã bật', 'Chưa bật']
                        }, null, null]
                    });
                }
                if ($(".table-date-6").length > 0) {
                    $.datepicker.setDefaults({
                        dateFormat: "dd/mm/yy"
                    });
                    oTable.columnFilter({
                        "sPlaceHolder": "head:after",
                        'sRangeFormat': "{from}{to}",
                        "aoColumns": [null, null, { type: "text" }, { type: "text" },
                            { type: "date-range" }, null]
                    });
                }
                if ($(".table-order").length > 0) {
                    $.datepicker.setDefaults({
                        dateFormat: "dd/mm/yy"
                    });
                    oTable.columnFilter({
                        "sPlaceHolder": "head:after",
                        'sRangeFormat': "{from}{to}",
                        "aoColumns": [null, null, { type: "text" }, { type: "text" }, {
                            type: "select", bCaseSensitive: true,
                            values: ['Đã bật', 'Chưa bật']
                        },{ type: "date-range" }, null]
                    });
                }
                if ($(".category-select").length > 0) {
                    var categoryHtml = $(".category-select").html();
                    $(".category-select").html("");
                    categoryHtml = "<label><span>Danh mục: </span>" + categoryHtml + "</label>&nbsp;&nbsp;";
                    $(".dataTables_filter label").before(categoryHtml);
                    $(".dataTables_filter select").addClass("list-category").chosen({ disable_search_threshold: 9999999 });
                    oTable.fnSetColumnVis(colLast + 1, false);// bVisible:false
                    $(".list-category").change(function () {
                        //Nếu muốn tìm tất cả liên quan đến
                        // oTable.fnFilter($(this).val(), null, false, true);
                        oTable.fnFilter($(this).val(), colLast + 1, false, true);
                    });
                }
                if ($(".table-product").length > 0) {
                    oTable.columnFilter({
                        "sPlaceHolder": "head:after",
                        "aoColumns": [null, null, { type: "text" }, null,
                            { type: "select", bCaseSensitive: true, values: ['Đã bật', 'Chưa bật'] }]
                    });
                }
                if ($(this).hasClass("dataTable-fixedcolumn")) {
                    new FixedColumns(oTable);
                }
                if ($(this).hasClass("dataTable-grouping")) {
                    var rowOpt = {};

                    if ($(this).attr("data-grouping") == 'expandable') {
                        rowOpt.bExpandableGrouping = true;
                    }
                    oTable.rowGrouping(rowOpt);
                }

                oTable.fnDraw();
                oTable.fnAdjustColumnSizing();
            }
        });
    }
    $(".btn-delall").click(function (ev) {
        ev.preventDefault();
    });
}
    // increment - nhấn tăng giảm
function numberIncrement() {
    $(".number-incremnet input").keypress(function () {
        return false;
    });
    $(".number-incremnet i").click(function () {
        var $parent = $(this).parent();
        var oldVal = $parent.find("input").val();
        var newVal = parseFloat(oldVal);
        if ($(this).attr("title") == "-") {
            newVal = newVal - 1;
        } else {
            newVal = newVal + 1;
        }
        if (newVal < 0)
            return;
        $parent.find("input").val(newVal);
    });
}
    // dropdownlist - select
function select() {
    if ($(".select2-me").length > 0) {
        $(".select2-me").select2();
    }
}
    // hiển thị hay ẩn thẻ cần
function ShowHide(eleID, ishow) {
    if (!ishow)
        $("#" + eleID).slideUp();
    else
        $("#" + eleID).slideDown();
}
    // lọc bỏ các dấu tiếng việt
function locdau(id_name, id_tit) {
    var isEmpty = $("#" + id_tit).val().trim().length > 0 ? false : true;
    $("#" + id_name).change(function () {
        if (isEmpty) {
            var str = $(this).val().toLowerCase();
            str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
            str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
            str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
            str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
            str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
            str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
            str = str.replace(/đ/g, "d");
            str = str.replace(/!|@|\$|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\'| |\"|\&|\#|\[|\]|~/g, "-");
            str = str.replace(/-+-/g, "-"); //thay thế 2- thành 1-
            str = str.replace(/^\-+|\-+$/g, "");//cắt bỏ ký tự - ở đầu và cuối chuỗi
            str = str.replace(/[^a-zA-Z0-9]/g, '-');
            $("#" + id_tit).val(str);
        }
    });
}

function CallMethodSV(NameMethod, paramter, onSuccess, asyn) {
    $.ajax({
        type: "POST",
        url: _url + "/Services/Response.aspx/" + NameMethod,
        dataType: "json",
        data: paramter,
        contentType: "application/json; charset=utf-8",
        success: onSuccess,
        async: asyn,
        Error: _fail
    });
}

function _fail(response) {
    alert("Có lỗi xảy ra yêu cầu làm lại.");
}

function GeneralDelete(method) {
    $("#cmdDelete").click(function (ev) {
        ev.preventDefault();
        var inputs = $(".table input[name=check]");
        var value = null;
        $.each(inputs, function (index, obj) {
            if ($(obj).parent().hasClass("checked")) {
                if (value != null)
                    value += "," + $(obj).val();
                else
                    value = $(obj).val();
            }
        });
        if (value != null) {
            var isDele = confirm("Bạn muốn xóa?");
            if (isDele) {
                CallMethodSV(method, $.toJSON({ ids: value }), function (d) {
                    if (d.d == 1) {
                        //alert("xóa thành công!");
                        window.location.reload();
                    }
                }, true);
            }
        }
        else
            alert("Bạn chưa chọn liên hệ cần xóa!");
    });
    $(".Delete").click(function (ev) {
        ev.preventDefault();
        var isDele = confirm("Bạn muốn xóa?");
        if (isDele) {
            var $thisItem = $(this);
            CallMethodSV(method, $.toJSON({ ids: $(this).attr("href") }), function (d) {
                if (d.d == 1) {
                    //alert("xóa thành công!");
                    $thisItem.parent().parent().remove();
                }
            }, true);
        }
    });
}

function GeneralActive(method) {
    $('span.label').click(function () {
        var id = $(this).attr("title");
        var $label = $(this);
        CallMethod(method, "{itemid:" + id + " }", function (data) {
            if (data.d == 1) {
                if ($label.attr("data-act") == "1") {
                    $label.attr("data-act", 0);
                    $label.removeClass("label-satgreen");
                    $label.addClass("label-lightred");
                    $label.html("Chưa bật");
                }
                else {
                    $label.attr("data-act", 1);
                    $label.removeClass("label-lightred");
                    $label.addClass("label-satgreen");
                    $label.html("Đã bật");
                }
            }
        });
    });
}

function genUpValue(method, name) {
    $(".table input[name=" + name + "]").click(function () {
        var value = 0;
        if ($(this).parent().hasClass("checked"))
            value = 0;
        else
            value = 1;
        CallMethod(method, $.toJSON({ type: $(this).prop("name"), itemid: $(this).val(), val: value }), function (data) {
            if (data.d == 1) {
            }
        });
    });
    if (name == "act") {
        $('span.label').click(function () {
            var id = $(this).attr("title");
            var $label = $(this);
            CallMethod(method, $.toJSON({ type: name, itemid: id, val: 0 }), function (data) {
                if (data.d == 1) {
                    if ($label.attr("data-act") == "1") {
                        $label.attr("data-act", 0);
                        $label.removeClass("label-satgreen");
                        $label.addClass("label-lightred");
                        $label.html("Chưa bật");
                    }
                    else {
                        $label.attr("data-act", 1);
                        $label.removeClass("label-lightred");
                        $label.addClass("label-satgreen");
                        $label.html("Đã bật");
                    }
                }
            });
        });
    }
    if (name == "delete") {
        GeneralDelete(method);
    }
}

function genValText(method, name) {
    $(".table input[name=" + name + "]").blur(function () {
        var oElement = $(this);
        CallMethod(method, $.toJSON({ type: $(this).prop("name"), itemid: $(this).prop("title"), val: $(this).val() }), function (data) {
            if (data.d == 1) {
                oElement.parent().find("span").text(oElement.val());
            }
        });
    });
}

function CallMethod(NameMethod, paramter, onSuccess) {
    $.ajax({
        type: "POST",
        url: _url + "/Services/Response.aspx/" + NameMethod,
        dataType: "json",
        data: paramter,
        contentType: "application/json; charset=utf-8",
        success: onSuccess,
        Error: function (ex) { alert(ex.toString()); }
    });
}

function PlugInTable() {
    $.fn.dataTableExt.afnSortData['dom-numeric'] = function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push(this.value * 1);
        });
        return aData;
    }

    /* Create an array with the values of all the select options in a column */
    $.fn.dataTableExt.afnSortData['dom-select'] = function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ') select', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push($(this).val());
        });
        return aData;
    }

    /* Create an array with the values of all the checkboxes in a column */
    $.fn.dataTableExt.afnSortData['dom-checkbox'] = function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push(this.checked == true ? "1" : "0");
        });
        return aData;
    }
}